<html>
<body>
Reports expressions of <code>byte</code> type returned from a method implementing the <code>InputStream.read()</code> method.
<p>
  This is suspicious because <code>InputStream.read()</code> should return a value in the range from <code>0</code> to <code>255</code>,
  while an expression of byte type contains a value from <code>-128</code> to <code>127</code>.
  The quick-fix converts the expression into an unsigned <code>byte</code> by applying the bitmask <code>0xFF</code>.
</p>
<p><b>Example:</b></p>
<pre><code lang="java">
class MyInputStream extends InputStream {
  int pos = 0;
  byte[] data;

  MyInputStream(byte[] input) {
    data = input;
  }

  @Override
  public int read() {
    if (pos == data.length) {
      return -1;
    }
    return data[pos++]; // problem
  }
}
</code></pre>
<p>After applying the quick-fix:</p>
<pre><code>
class MyInputStream extends InputStream {
  int pos = 0;
  byte[] data;

  MyInputStream(byte[] input) {
    data = input;
  }

  @Override
  public int read() {
    if (pos == data.length) {
      return -1;
    }
    return data[pos++] & 0xFF;
  }
}
</code></pre>

<!-- tooltip end -->
<p><small>New in 2023.2</small></p>
</body>
</html>
